package com.jmyd.txlcn.base.vo;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 下拉框专用vo
 *
 * @author samphin
 * @date 2020-9-2 10:06:35
 */
public class LabelVo {

    /**
     * 字段名称
     */
    private Integer key;

    /**
     * 字段值
     */
    private Object value;

    public Integer getKey() {
        return key;
    }

    public void setKey(Integer key) {
        this.key = key;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    public List<LabelVo> build(List<LabelStringKeyVo> sourceVoList) {
        if (sourceVoList == null || sourceVoList.isEmpty()) {
            return new ArrayList<>(1);
        }
        return sourceVoList.stream().map(sourceVo -> {
            LabelVo labelVo = new LabelVo();
            labelVo.setKey(Integer.valueOf(sourceVo.getKey()));
            labelVo.setValue(sourceVo.getValue());
            return labelVo;
        }).collect(Collectors.toList());
    }
}
